package com.tyersoft.kickcalendar;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;

public class AppManager {
	private static AppManager _instance;
	private static long CurrentDate = Calendar.getInstance().getTimeInMillis();

	private AppManager() {
		
	}

	public static AppManager getInstance() {
		if (_instance == null) {
			_instance = new AppManager();
		}
		return _instance;
	}

	public static void setCurrentDate(long date) {
		CurrentDate = date;
	}
	
	/*
	 * Get CurrentDate as milliseconds
	 */
	public static long getCurrentDate() {
		return CurrentDate;
	}
	
	/**
	 *  Get CurrentDate in yyyy-MM-dd formt
	 **/
	public static String getCurrentDay() {
		return getDay(CurrentDate);
	}
	
	/**
	 *  Get Date in yyyy-MM-dd format
	 **/
	public static String getDay(long Date) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd",Locale.getDefault());
		Calendar calendar = Calendar.getInstance();
		calendar.setTimeInMillis(Date);
		return formatter.format(calendar.getTime());
	}
}